
/*******************************************************************************************************

Figure 2: Parallel trends plots

*******************************************************************************************************/

*Set director path
cd "C:\Users\tsa23\Documents\petitions\replication files"

clear all

*read in our main dataset
use dta\did_rep.dta


*Elminate contrituencies which are not part of case G
drop if ID == 45 //University of Cambridge
drop if ID == 191 //University of Oxford
keep if new == 1 | drummond == .
drop if year==1830 | year==1831 | year==1832

gen treatgroup = 0
replace treatgroup =  1 if new==1 

collapse ln_petitions, by(year treatgroup)

label var ln_petitions "Log petitions"

gen ln_petitions_T=ln_petitions if treatgroup==1
label var ln_petitions_T "Treatment group"
gen ln_petitions_C=ln_petitions if treatgroup==0
label var ln_petitions_C "Control group"

sort treatgroup
sort year

set scheme plotplainblind

 twoway ///
  /// Segment 1 (years < 1833)
    (scatter ln_petitions_T year if year < 1833,          msymbol(circle) msize(medium) mcolor(black)) ///
    (line    ln_petitions_T year if year < 1833,             lcolor(black)    lwidth(medthick) lp(solid)) ///
    (scatter ln_petitions_C year if year < 1833,          msymbol(oh)     msize(large)  mcolor(black)) ///
    (line    ln_petitions_C year if year < 1833,             lcolor(black)     lwidth(medthick) lp(shortdash)) ///
    /// Segment 2 (years >= 1833)
    (scatter ln_petitions_T year if year >= 1833,         msymbol(circle) msize(medium) mcolor(black)) ///
    (line    ln_petitions_T year if year >= 1833,            lcolor(black)    lwidth(medthick) lp(solid)) ///
    (scatter ln_petitions_C year if year >= 1833,         msymbol(oh)     msize(large)  mcolor(black)) ///
    (line    ln_petitions_C year if year >= 1833,            lcolor(black)     lwidth(medthick) lp(shortdash)) ///
    , ytitle("Log(petitions+1)") ///
      legend(order(1 "Treatment" 3 "Control")) ///
      title(" ") ///
      xline(1831, lcolor(black) lwidth(medthick)) ///
      xlabel(1820 1825 1829 1833 1838)
      
graph save "graphs\figure2a.gph", replace
display

graph export graphs\figure2a.pdf, as(pdf) name("Graph") replace


clear all

*read in our main dataset
use dta\did_rep.dta


*Elminate contrituencies which are not part of case L
drop if ID == 45 //University of Cambridge
drop if ID == 191 //University of Oxford
keep if sch_A==1 | sch_B == 1 | drummond!=.
drop if year==1830 | year==1831 | year==1832

gen treatgroup = 0
replace treatgroup =  1 if sch_A==1 

collapse ln_petitions, by(year treatgroup)

*gen ln_petitions = log(petitions+1)
label var ln_petitions "Log petitions"

gen ln_petitions_T=ln_petitions if treatgroup==1
label var ln_petitions_T "Treatment group"
gen ln_petitions_C=ln_petitions if treatgroup==0
label var ln_petitions_C "Control group"


sort treatgroup
sort year

set scheme plotplainblind

twoway ///
  /// Segment 1 (years < 1833)
    (scatter ln_petitions_T year if year < 1833,          msymbol(circle) msize(medium) mcolor(black)) ///
    (line    ln_petitions_T year if year < 1833,             lcolor(black)    lwidth(medthick) lp(solid)) ///
    (scatter ln_petitions_C year if year < 1833,          msymbol(oh)     msize(large)  mcolor(black)) ///
    (line    ln_petitions_C year if year < 1833,             lcolor(black)     lwidth(medthick) lp(shortdash)) ///
    /// Segment 2 (years >= 1833)
    (scatter ln_petitions_T year if year >= 1833,         msymbol(circle) msize(medium) mcolor(black)) ///
    (line    ln_petitions_T year if year >= 1833,            lcolor(black)    lwidth(medthick) lp(solid)) ///
    (scatter ln_petitions_C year if year >= 1833,         msymbol(oh)     msize(large)  mcolor(black)) ///
    (line    ln_petitions_C year if year >= 1833,            lcolor(black)     lwidth(medthick) lp(shortdash)) ///
    , ytitle("Log(petitions+1)") ///
      legend(order(1 "Treatment" 3 "Control")) ///
      title(" ") ///
      xline(1831, lcolor(black) lwidth(medthick)) ///
      xlabel(1820 1825 1829 1833 1838)
     
      
graph save "graphs\figure2b.gph", replace
display

graph export graphs\figure2b.pdf, as(pdf) name("Graph") replace
